<?php

namespace App\Jobs;

use App\GameChannel\PayGameCallback;
use App\Models\Orders;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class PayGameCbQueue implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    use TraitQueue;

    protected $tradeNo;
    protected $status;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($trade_no, $status)
    {
        $this->tradeNo = $trade_no;
        $this->status = $status;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $obj = new PayGameCallback($this->tradeNo);
        switch ($this->status) {
            case (Orders::PAY_STATUS_PAY_OK):
                $obj->cbGameByPayOk();
                break;

            case (Orders::PAY_STATUS_CALLBACK_ERR):
                $obj->cbGameByCbErr();
                break;
        }
    }
}
